Fix out of array out of bounds issue.