added piecewise