I made a template including a matrix field. I want to wrap all occurrences of a certain block type into a `<ul>` element. How can I do this?

My current code:
  
 

     {% for block in entry.matrixField.all() %}
            {% switch block.type %}
                {% case 'blockType1' %}
                <div>
                    {{ block.field }}
                </div>
                {% case 'blockType2' %}
                <div>
                    {{ block.field }}
                </div>
                {% case 'blockType3' %}
                <ul>
                    <li>
                        {{ block.field }}
                    </li>
                </ul>
            {% endswitch %}
        {% endfor %}

Current output:

    <ul>
        <li>blockfield</li>
    </ul>
    <ul>
        <li>blockfield</li>
    </ul>
    <ul>
        <li>blockfield</li>
    </ul>

But I want my output like this:

    <ul>
        <li>blockfield</li>
        <li>blockfield</li>
        <li>blockfield</li>
    </ul>

That is, I want the `ul` tag to follow the loop of blockType3.