bugfix in disconnect code