Added preliminary state machine