Thanks for your script. You have to solve this within one script, I dont think its possible with multiple scripts.

But you can simplify your script to make things easier. I have created a sample script, maybe this will be a starting point for your solution.