fix some bugs on template