refactor authorize mode