Custom function in template