First of all, this is one of my first scripts, so I didn't even know it could be writed better than this. It works, then for me it's fine.
But, if you have any suggestion for a better code I'm happy to read you.
Second, I couldn't find any APIs that remove points. I found setValue only.
And yes, I'm writing with JavaScript.