i took this from the Negotiation lib .. but yeah maybe not the ideal API to copy.