Fix check for undefined variables