finish refactoring project as a state machine