Fix issue with undeclared variable that leaks to global scope

Just noticed that the undeclared variable appears in the global scope and probably not what was intended.