Corrected index of the validpoints array

(needs testing)