Updating queries to work with unique ids