modify maxAndMin function