Refined the login process