small change to CalculateMinAndMax