code cleanup
fix index shift

when adding and removing items in an array, it introduces a shift, that
must be propagated to remaining elements for calculating operation paths