add control of connection lost