fix some bugs in extract()