changed assert to exception