changed function name to make more sense, used ES5's reduce