Adding optimizer to map reduce