added support for custom templates