Updating structural framing created in dynamo

Hi All,
I’m struggling to keep this model parametric. I’ve created a graph to create a portal frame and practice with, similar to many youtube tutorials. It worked perfectly to created the initial model, but now the structural framing has been created, I can’t now update the structural framing correctly in Revit without it throwing errors.

If I close and reopen the model as one would on a real project, and then want to reduce the number of bays for example, or decrease the overall width, it’ll throw up multiple “can’t join geometry” messages and then it won’t update correctly in revit. I’ve tried linking all elements to an unjoinall node at the end however as the geometry is already created it feels too late and created weirder results (see image below), I just can’t work out where to place it or a workaround.

Also, I’m aware there’s a structural framing package that has nodes like frame.copy but i was trying to recreate it with ootb nodes. If that’s the best answer then sobeit, but i think i’m not understanding the creation or updating of the structural framing correctly. Thanks for any help anyone can offer, I hope the graph is concise enough.
portal_frame_test.dyn (772.5 KB)

After some review I’ve realised that the error is caused by how I create the vertical x-bracing in the first and last bays. It seems that if I create the bracing in every bay, then delete the structural framing afterwards everything works fine. I can reopen the graph and update everything as I want. However, if I try to filter the bays I want prior to creating the structural framing, using list.getitematindex, the graph will create the geometry once but then throw errors in Revit when I try to update the number of bays. Can anyone help me understand why?

The graph works, but deleting something immediately after creating it feels clunky and inefficient.

Updated and hopefully clearer graph attached

portalframetest.dyn (554.2 KB)