Sub-state machine design, needs further implementation.