refactored  animation example