Change design to state machine