Nearly perfected the JS for animating GIFs