Rearchitect queries