Refactoring mapper and reducer for deprecated API