updated the toc generation function