I would highly recommend @pturmel's Integration Toolkit to do dataset manipulations in an expression to dodge scripting transforms. Much faster and efficient.
Double check and make sure that you don't have an accidental copy/pasted change script that is setting the selection to index 0.