refactor code and add animations