working animation, some refactoring