added parameter to reduce function