added ability to pass function as template param