restructured query builder