refactoring auth code
more auth code refactoring