change if ... error to assert