Add reduce algorithm