Added map/reduce code