Rewrite and finish insert in full recursive logic