fixed disconnect logic