template extraction