template for algorithm