fix the list index bug