tempalte function completed