replace reduce by max