use RuntimeError instead of asserts