make function in templates actually work