use template for method function