Refactored Animation Code