Added state logic.