template utility function improvements