updated map_reduce script