Fix wrong max/min