fix bugs in negotiation