Refactored some of the rotation functions