changed assert to throw