The acid chloride functionality reacts with the aromatic amine to give the amide bond and hydrochloric acid (HCl) as a by-product. In the commercial preparation of polyamideimides, the polymerization is carried out in a dipolar, aprotic solvent such as N-methylpyrrolidone (NMP), dimethylacetamide (DMAC), dimethylformamide (DMF), or dimethylsulfoxide (DMSO) at temperatures between 20-60 °C. The byproduct HCl must be neutralized in situ or removed by washing it from the precipitated polymer. Further thermal treatment of the polyamideimide polymer increases molecular weight and causes the amic acid groups to form imides with the evolution of water.