Adding tlac's dual query code