add init method to function template for using previously defined variables in functions