Fixing list out of index bug