fixed bugs with map reduce