refactored animation functions