reduce function implement now