upate reduce function