changed order of disconnect