Repaired the piecewise test