refactoring the animation