improved logout functionality