structure the queries