MinMaxing correctly