added auto-reconnect in case of network failure