Refactor the negotiate() and connected functions