added support for templates