State machines are wonderful tools