fixed list index bug and put index reset counter in code