writing map reduce