Small refactor animation code