fix the functions of template