change accumulating loop to keep two index lists

Percentage list is used for final data accumulating.
Number list is used to compare with current index.
add some unit tests