Implemented handle_state.