previously this function would use the array length, but now it scans the array looking for the first sentinel that occurs.