Well... I was able to simplify my last script, as you can see it is much better now