refactoring solution for clarity