added check to report connection error