Without looking at the example it is not possible to know whether N or x is the sentinel value. Fix it.