reduced reduce function