uses proper condition for animation loop