added disconnecting handling