Tried to keep index within range. Unsolved issue.