fix template merging