Added disconnect handling