Handle logout better