change assert to exception