changed map reduce from using array reduce to foreach.

foreach is the lame way of doing it but array.reduce was only working sometimes.
whatever