changing some assertions to exceptions