Fix bugs in list index