auth refactor