Optimize the auto reply function.