Fix possible out of range vector access