Adding reconnect logic