improve login/logout functionality