Fixed code in map reduce