added reduce fcn