added reconnect logic