fix find max min bug