removed animations length cached variable because the length can change while the for loop is running