handle connection errors more gracefully