Check before running query