Adding reconnect  logic