Fixed out-of-bounds error