cubicspline method refactoring