improved logout helper method