add pmax and pmin