Converted functions to templates