use macro to eleminate duplicate codes
fix toc bug