PartitionIndex is now used instead of nested while loops