Map-reduce code