Fix a variable scope issue