Changed logout logic