Added state machines to make the game run