move template related function to submodule