OK, I see what you mean. I've added the variables.
There is still apparently some coding errors (I am always pointed to line 28), but when I try to delete the line, it tells me it is rejecting the change. Do you see anything in the attached file?
By the way, I've replaced the Show If and Repeat Region with your scripts.