Big code abstraction in animate.js