implementing reduction