fine tuned the login/logout functionality