Updated to use an animation loop