template functions