replaced assertions with K exceptions