reconnect function (untested)