refactoring solution