Throw IllegalStateException instead of using asserts