Refactoring solution