created new variable and changed for loop condition.