---
description: Refactor code while preserving behavior
---
Refactor the following code. Goals:

1. **Preserve behavior** — No functional changes
2. **Reduce complexity** — Simplify logic, extract functions if needed
3. **Improve naming** — Clear, descriptive names
4. **Remove duplication** — DRY without over-abstracting
5. **Follow conventions** — Match the project's existing style

Show the refactored code with a brief explanation of each change.

$@
