refactor, fix some bugs and implement default template part3