Fix when min and max comparasion