Refactoring for clarity and reusability