fix some bugs in crawl function