Add ability to pass function as template