Improved error message for undefined variables