Fix list indices out of range