Calculating averages with map and reduce