implemented connection recovery