switched calculate to use map.reduce, long form