logout logic cleaned up