better state machines, added to example