added template for algorithm function