made the state machine object oriented