I moved the logic to the `closeUnopenedTag` function as you suggested.