Fix a variable hoisting issue