refactored code to check for numeric variables and display an error if the variable isn't numeric