refactored for new auth flow