Fix in min max algorithm