algorithm templata