Added correct script this time...

I added the incomplete rewrite by accident...
However all changes from last commit were carried over