Added missing index in for loop