Fixed variable declaration in for loop