fix bugs in extract toc