Fix redeclaration of loop variable