Error checking on min and max value