Correct variable scope resolution