updated connection retrying method