Fixed handling the state