moved state machine into an object
changed main