Fixed the list index problem