refactoring and adding some animation