reconnection logic