template helper functions