adding map reduce functional code