Converted the animate and rotate functions to allow for complex animations