Just a side note that you don’t have to check app variables for null values. That’s only something you need to do for stored variables. You could probably simplify that code quite a bit…
But in terms of finding the source of the crash, I’d recommend doing some block-by-block debugging. I have a method I use that works pretty well: Debugging in Thunkable X (Video)