Fix bug: variable is always local