Fixed position error in animation function