better query validation