Addressed comments: made templateId optional