another refactor for flow control, start using sanity checks