smarter implementation of the uri label query