refactoring reduce