replace early exits with asserts