Improvement of the animation code