refactoring user authentication and manager