Adding templates and loops