reduce too many calling of reactants.size() and products.size()