Besides hydrolysis and alcoholysis, aminolysis is another nucleophilic acyl substitution reaction involving ammonia or amines as nucleophiles. Acid halides react with ammonia, producing primary amides. Primary amines give secondary amides, and secondary amines yield tertiary amides. The aminolysis mechanism begins with a nucleophilic attack by the amine at the carbonyl carbon, forming a tetrahedral intermediate. Next, the carbonyl is reconstructed, and the halide ion departs as a leaving group. The last step involves deprotonation of the amide nitrogen by another equivalent of the amine, giving the substitution product along with the ammonium salt. The reaction is typically carried out in excess amine, one equivalent for the nucleophilic attack and the second as a base in the final proton transfer step. However, if the amine is expensive, relatively inexpensive bases like pyridine or sodium hydroxide are used for deprotonation.