Refractor map, implement reduce