Fixed bugs in max min setting