In this reaction , either excess of halide salts are taken or this reaction is carried out in a solvent , in which the reagent used is most soluble. but in the product , the salt of reagent is precipitated out and the 100 % product is obtained.
cn refer any book fr this or even wikipedia