A study of the mechanism of interfacial polyamidation and polyesterification