fix bug in the auto-reconnect code