added usage of variable in for loop being accessed outside for loop declaration