added Reduce function