design data reduce algorithm