implement template merging
implement template merging