Use a reduce instead of forEach