The code should check for valid values before trying to use them