modified extract schema algorithm