added template merging