added support for adding and updating templates