Fix array out of bounds