refactoring for login_manager