Code refactoring for login_window.