fix a bug which connection issue will stop program