Adding reconnect code