added check to disconnect patient