move template functions to own file