made the animation functions more dynamic