changed max to min