Thanks ralf!

I'll update the script to your solution.