Made the animation code a bit cleaner