refactored so the variable value is displayed in the error message