Fix issue with undeclared variable that leaks to global scope