In some cases the type check causes a fatal error when a non-numeric character or empty string is entered. The type coercion fails for those cases. Make sure an explicit integer conversion is performed for each value.