fix off by one for piece-wise linear case
correct fix (?)