modify function extract to merge some case and add some comments