reduce function added