optimized map reduce