Fixed setting loop variable