added auto reconnection