made code much leaner with less spline fitting