replace asserts with exception