Started adding piecewise implementation