Fixed out-of-bounds bug.