refactoring map/reduce organization