Fix bug in call to piecewise function