Added a state engine