repaired min and max