Add templated function