Error checking on min and max values