add templates and some functions