improved xds logic