Refactored auto-rotate