optimize disconnect()