Organize the login process code. Small changes to command mode