fixed reconnect logic