It does the above.
Wish I could advise on the original script:
But I don’t understand it and there’s some bad juju there. Never attempt to pull data out of a non-exec node like that. It will not work the way you think.