Converted for loops to while loops in EdgePartition.