improved logout method