refactored animation and entity code