document state machine