refactor the auto orientation