Throwing exception instead of asserts