template all functions