Instead of replacing all the tags, can we just replace the first section tag with the one we've just constructed.

(Also, we shouldn't assume that the section tag is necessarily the first tag.  It'll be the first tag of type "section".)