abstract out addPeer logic