Thank you @ptrblck, this is a straight forward solution, since you build the tensor positions that are about to change.
That was my first attempt too, and while trying, I thought that maybe there is a build-in function doing that. Anyway, it is a nice solution.