optimize map/reduce