Refactoring auth