simplify reduce implementation