move template function to header file to make the program pass compilation