Implemented the state control
Enhanced flow