adding some correction and a disconnect function