Added exception handling for a disconnect