apply modular arithmetic so make the looping natural spline cyclic