refactoring auth module