separated out all piecewise functions