Rework State Machine