add reconnection logic