Fix bug with loop variable address reference