use add.reduce instead of sum