Query checking