Use reduce instead of each