added support for disconnecting and reconnecting