New way of doing the whole state machine