Hello Dimpie,
Welcome to the community and good to see that you found your first solution here.
I just want to point you to an alternative solution I found in the forum these days to add/ increment easily a value to a global variable:
Might reduce lines in the code
Cheers
Ranki