Improve login logic.