Fixed out-of-range indices