Skip to main content
Chemistry LibreTexts

7.2 The Equilibrium Constant

  • Page ID
    163816
  • Skills to Develop

    • To write an equilibrium constant expression for any reaction.

    Because an equilibrium state is achieved when the forward reaction rate equals the reverse reaction rate, under a given set of conditions there must be a relationship between the composition of the system at equilibrium and the kinetics of a reaction (represented by rate constants). We can show this relationship using the decomposition reaction of \(N_2O_4\) to \(NO_2\). Both the forward and reverse reactions for this system consist of a single elementary reaction, so the reaction rates are as follows:

    \[\text{forward rate} = k_f[N_2O_4] \label{Eq1}\]

    and

    \[\text{reverse rate} = k_r[NO_2]^2 \label{Eq2}\]

    At equilibrium, the forward rate equals the reverse rate (definition of equilibrium):

    \[ k_f[N_2O_4] = k_r[NO_2]^2 \label{Eq3}\]

    so

    \[\dfrac{k_f}{k_r}=\dfrac{[NO_2]^2}{[N_2O_4]} \label{Eq4}\]

    The ratio of the rate constants gives us a new constant, the equilibrium constant (\(K\)), which is defined as follows:

    \[K=\dfrac{k_f}{k_r} \label{Eq5}\]

    Hence there is a fundamental relationship between chemical kinetics and chemical equilibrium: under a given set of conditions, the composition of the equilibrium mixture is determined by the magnitudes of the rate constants for the forward and the reverse reactions.

    Many reactions occur by a multi-step mechanism, and so the equilibrium composition can not be so easily derived as shown in the above example. However it is universally true that the numerical value of the equilibrium constant of a system at equilibrium at a specific temperature will always have a constant value, as shown below.

     

    Table \(\PageIndex{1}\) lists the initial and equilibrium concentrations from five different experiments using the reaction system described by Equation \(\ref{Eq3}\). At equilibrium the magnitude of the quantity \([NO_2]^2/[N_2O_4]\) is essentially the same for all five experiments. In fact, no matter what the initial concentrations of \(NO_2\) and \(N_2O_4\) are, at equilibrium the quantity \([NO_2]^2/[N_2O_4]\) will always be \(6.53 \pm 0.03 \times 10^{−3}\) at 25°C, which corresponds to the ratio of the rate constants for the forward and reverse reactions. That is, at a given temperature, the equilibrium constant for a reaction always has the same value, even though the specific concentrations of the reactants and products vary depending on their initial concentrations.

    Table \(\PageIndex{1}\): Initial and Equilibrium Concentrations for \(NO_2:N_2O_4\) Mixtures at 25°C
      Initial Concentrations Concentrations at Equilibrium  
    Experiment [\(N_2O_4\)] (M) [\(NO_2\)] (M) [\(N_2O_4\)] (M) [\(NO_2\)] (M) \(K = [NO_2]^2/[N_2O_4]\)
    1 0.0500 0.0000 0.0417 0.0165 \(6.54 \times 10^{−3}\)
    2 0.0000 0.1000 0.0417 0.0165 \(6.54 \times 10^{−3}\)
    3 0.0750 0.0000 0.0647 0.0206 \(6.56 \times 10^{−3}\)
    4 0.0000 0.0750 0.0304 0.0141 \(6.54 \times 10^{−3}\)
    5 0.0250 0.0750 0.0532 0.0186 \(6.50 \times 10^{−3}\)

    Developing an Equilibrium Constant Expression

    In 1864, the Norwegian chemists Cato Guldberg (1836–1902) and Peter Waage (1833–1900) carefully measured the compositions of many reaction systems at equilibrium. They discovered that for any reversible reaction of the general form

    \[aA+bB \rightleftharpoons cC+dD \label{Eq6}\]

    where A and B are reactants, C and D are products, and a, b, c, and d are the stoichiometric coefficients in the balanced chemical equation for the reaction, the ratio of the product of the equilibrium concentrations of the products (raised to their coefficients in the balanced chemical equation) to the product of the equilibrium concentrations of the reactants (raised to their coefficients in the balanced chemical equation) is always a constant under a given set of conditions. This relationship is known as the law of mass action and can be stated as follows:

    \[K=\dfrac{[C]^c[D]^d}{[A]^a[B]^b} \label{Eq7}\]

    where \(K\) is the equilibrium constant for the reaction. Equation \(\ref{Eq6}\) is called the equilibrium equation, and the right side of Equation \(\ref{Eq7}\) is called the equilibrium constant expression. The relationship shown in Equation \(\ref{Eq7}\) is true for any pair of opposing reactions regardless of the mechanism of the reaction or the number of steps in the mechanism.

    The equilibrium constant can vary over a wide range of values. The values of \(K\) shown in Table \(\PageIndex{2}\), for example, vary by 60 orders of magnitude. Because products are in the numerator of the equilibrium constant expression and reactants are in the denominator, values of K greater than 1 indicate a reaction that is product-favored at equilibrium (-\(\Delta G^o\)). If K is greater than \(10^3\), the reaction has a strong tendency for the reactants to form products. In this case, chemists say that equilibrium lies far to the right as written, favoring the formation of a great deal of products. An example is the reaction between \(H_2\) and \(Cl_2\) to produce \(HCl\), which has an equilibrium constant of \(1.6 \times 10^{33}\) at 300 K. Because \(H_2\) is a good reductant and \(Cl_2\) is a good oxidant, the reaction proceeds essentially to completion. In contrast, values of \(K\) less than 1 indicate a reaction that is reactant-favored at equilibrium (+\(\Delta G^o\)). If K is less than \(10^{-3}\) the reaction has a very slight tendency for the reactants to form products, so that the ratio of products to reactants at equilibrium is very small. That is, reactants do not tend to form products readily, and the equilibrium lies to the left as written, favoring the formation of reactants.

    Table \(\PageIndex{2}\): Equilibrium Constants for Selected Reactions*
    Reaction Temperature (K) Equilibrium Constant (K)
    *Equilibrium constants vary with temperature. The K values shown are for systems at the indicated temperatures.
    \(S_{(s)}+O_{2(g)} \rightleftharpoons SO_{2(g)}\) 300 \(4.4 \times 10^{53}\)
    \(2H_{2(g)}+O_{2(g)} \rightleftharpoons 2H2O_{(g)}\) 500 \(2.4 \times 10^{47}\)
    \(H_{2(g)}+Cl_{2(g)} \rightleftharpoons 2HCl_{(g)}\) 300 \(1.6 \times 10^{33}\)
    \(H_{2(g)}+Br_{2(g)} \rightleftharpoons 2HBr_{(g)}\) 300 \(4.1 \times 10^{18}\)
    \(2NO_{(g)}+O_{2(g)} \rightleftharpoons 2NO_{2(g)}\) 300 \(4.2 \times 10^{13}\)
    \(3H_{2(g)}+N_{2(g)} \rightleftharpoons 2NH_{3(g)}\) 300 \(2.7 \times 10^{8}\)
    \(H_{2(g)}+D_{2(g)} \rightleftharpoons 2HD_{(g)}\) 100 \(1.92\)
    \(H_{2(g)}+I_{2(g)} \rightleftharpoons 2HI_{(g)}\) 300 \(2.9 \times 10^{−1}\)
    \(I_{2(g)} \rightleftharpoons 2I_{(g)}\) 800 \(4.6 \times^{ 10−7}\)
    \(Br_{2(g)} \rightleftharpoons 2Br_{(g)}\) 1000 \(4.0 \times 10^{−7}\)
    \(Cl_{2(g)} \rightleftharpoons 2Cl_{(g)}\) 1000 \(1.8 \times 10^{−9}\)
    \(F_{2(g)} \rightleftharpoons 2F_{(g)}\) 500 \(7.4 \times 10^{−13}\)

    You will also notice in Table \(\PageIndex{2}\) that equilibrium constants have no units, even though Equation \(\ref{Eq7}\) suggests that the units of concentration might not always cancel because the exponents may vary. In fact, equilibrium constants are calculated using “effective concentrations,” or activities, of reactants and products, which are the ratios of the measured concentrations to a standard state of 1 M. As shown in Equation \(\ref{Eq8}\), the units of concentration cancel, which makes \(K\) unitless as well:

    \[ \dfrac{[A]_{measured}}{[A]_{standard\; state}}=\dfrac{\cancel{M}}{\cancel{M}} = \dfrac{\cancel{\frac{mol}{L}}}{\cancel{\frac{mol}{L}}} \label{Eq8}\]

    In fact, equilibrium constants are calculated using “effective concentrations,” or activities, of reactants and products, which are the ratios of the measured concentrations to a standard state of 1 M.

    Many reactions have equilibrium constants between 1000 and 0.001 (\(10^3 \ge K \ge 10^{−3}\)), neither very large nor very small. At equilibrium, these systems tend to contain significant amounts of both products and reactants, indicating that there is not a strong tendency to form either products from reactants or reactants from products. An example of this type of system is the reaction of gaseous hydrogen and deuterium, a component of high-stability fiber-optic light sources used in ocean studies, to form \(HD\):

    \[H_{2(g)}+D_{2(g)} \rightleftharpoons 2HD_{(g)} \label{Eq9}\]

    The equilibrium constant expression for this reaction is

    \[K= \dfrac{[HD]^2}{[H_2][D_2]}\]

    with \(K\) varying between 1.9 and 4 over a wide temperature range (100–1000 K). Thus an equilibrium mixture of \(H_2\), \(D_2\), and \(HD\) contains significant concentrations of both product and reactants.

    Figure \(\PageIndex{3}\) summarizes the relationship between the magnitude of K and the relative concentrations of reactants and products at equilibrium for a general reaction, written as reactants \(\rightleftharpoons\) products.

    150621824376404.png

    Figure \(\PageIndex{3}\): The Relationship between the Composition of the Mixture at Equilibrium and the Magnitude of the Equilibrium Constant. The larger the K, the farther the reaction proceeds to the right before equilibrium is reached, and the greater the ratio of products to reactants at equilibrium.

    A large value of the equilibrium constant \(K\) means that products predominate at equilibrium; a small value means that reactants predominate at equilibrium.

    Example \(\PageIndex{1}\): equilibrium constant expressionS

    Write the equilibrium constant expression for each reaction.

    • \(N_{2(g)}+3H_{2(g)} \rightleftharpoons 2NH_{3(g)}\)
    • \(CO_{(g)}+\frac{1}{2}O_{2(g)} \rightleftharpoons CO_{2(g)}\)
    • \(2CO_{2(g)} \rightleftharpoons 2CO_{(g)}+O_{2(g)}\)

    Given: balanced chemical equations

    Asked for: equilibrium constant expressions

    Strategy:

    Refer to Equation \(\ref{Eq7}\). Place the arithmetic product of the concentrations of the products (raised to their stoichiometric coefficients) in the numerator and the product of the concentrations of the reactants (raised to their stoichiometric coefficients) in the denominator.

    Solution:

    The only product is ammonia, which has a coefficient of 2. For the reactants, \(N_2\) has a coefficient of 1 and \(\ce{H2}\) has a coefficient of 3. The equilibrium constant expression is as follows:

    \[\dfrac{[NH_3]^2}{[N_2][H_2]^3}\]

    The only product is carbon dioxide, which has a coefficient of 1. The reactants are \(CO\), with a coefficient of 1, and \(O_2\), with a coefficient of \(\frac{1}{2}\). Thus the equilibrium constant expression is as follows:

    \[\dfrac{[CO_2]}{[CO][O_2]^{1/2}}\]

    This reaction is the reverse of the reaction in part b, with all coefficients multiplied by 2 to remove the fractional coefficient for \(O_2\). The equilibrium constant expression is therefore the inverse of the expression in part b, with all exponents multiplied by 2

    \[\dfrac{[CO]^2[O_2]}{[CO_2]^2}\]

    Exercise \(\PageIndex{1}\)

    Write the equilibrium constant expression for each reaction.

    1. \(N_2O_{(g)} \rightleftharpoons N_{2(g)}+\frac{1}{2}O_{2(g)}\)
    2. \(2C_8H_{18(g)}+25O_{2(g)} \rightleftharpoons 16CO_{2(g)}+18H_2O_{(g)}\)
    3. \(H_{2(g)}+I_{2(g)} \rightleftharpoons 2HI_{(g)}\)
    Answer a

    \(K=\dfrac{[N_2][O_2]^{1/2}}{[N_2O]}\)

    Answer b

    \(K=\dfrac{[CO_2]^{16}[H_2O]^{18}}{[C_8H_{18}]^2[O_2]^{25}}\)

    Answer c

    \(K=\dfrac{[HI]^2}{[H_2][I_2]}\)

    Example \(\PageIndex{2}\)

    Predict which systems at equilibrium will (a) contain essentially only products, (b) contain essentially only reactants, and (c) contain appreciable amounts of both products and reactants.

    1. \(H_{2(g)}+I_{2(g)} \rightleftharpoons 2HI_{(g)}\;\;\; K_{(700K)}=54\)
    2. \(2CO_{2(g)} \rightleftharpoons 2CO_{(g)}+O_{2(g)}\;\;\; K_{(1200K)}=3.1 \times 10^{−18}\)
    3. \(PCl_{5(g)} \rightleftharpoons PCl_{3(g)}+Cl_{2(g)}\;\;\; K_{(613K)}=97\)
    4. \(2O_{3(g)} \rightleftharpoons 3O_{2(g)} \;\;\; K_{(298 K)}=5.9 \times 10^{55}\)

    Given: systems and values of \(K\)

    Asked for: composition of systems at equilibrium

    Strategy:

    Use the value of the equilibrium constant to determine whether the equilibrium mixture will contain essentially only products, essentially only reactants, or significant amounts of both.

    Solution:

    1. Only system 4 has \(K \gg 10^3\), so at equilibrium it will consist of essentially only products.
    2. System 2 has \(K \ll 10^{−3}\), so the reactants have little tendency to form products under the conditions specified; thus, at equilibrium the system will contain essentially only reactants.
    3. Both systems 1 and 3 have equilibrium constants in the range \(10^3 \ge K \ge 10^{−3}\), indicating that the equilibrium mixtures will contain appreciable amounts of both products and reactants.

    Exercise \(\PageIndex{2}\)

    Hydrogen and nitrogen react to form ammonia according to the following balanced chemical equation:

    \[3H_{2(g)}+N_{2(g)} \rightleftharpoons 2NH_{3(g)}\]

    Values of the equilibrium constant at various temperatures were reported as

    • \(K_{25°C} = 3.3 \times 10^8\),
    • \(K_{177°C} = 2.6 \times 10^3\), and
    • \(K_{327°C} = 4.1\).
    1. At which temperature would you expect to find the highest proportion of \(H_2\) and \(N_2\) in the equilibrium mixture?
    2. Assuming that the reaction rates are fast enough so that equilibrium is reached quickly, at what temperature would you design a commercial reactor to operate to maximize the yield of ammonia?
    Answer a

    327°C, where \(K\) is smallest

    Answer b

    25°C

    Variations in the Form of the Equilibrium Constant Expression

    Because equilibrium can be approached from either direction in a chemical reaction, the equilibrium constant expression and thus the magnitude of the equilibrium constant depend on the form in which the chemical reaction is written. For example, if we write the reaction described in Equation \(\ref{Eq6}\) in reverse, we obtain the following:

    \[cC+dD \rightleftharpoons aA+bB \label{Eq10}\]

    The corresponding equilibrium constant \(K′\) is as follows:

    \[K'=\dfrac{[A]^a[B]^b}{[C]^c[D]^d} \label{Eq11}\]

    This expression is the inverse of the expression for the original equilibrium constant, so \(K′ = 1/K\). That is, when we write a reaction in the reverse direction, the equilibrium constant expression is inverted. For instance, the equilibrium constant for the reaction \(N_2O_4 \rightleftharpoons 2NO_2\) is as follows:

    \[K=\dfrac{[NO_2]^2}{[N_2O_4]} \label{Eq12}\]

    but for the opposite reaction, \(2 NO_2 \rightleftharpoons N_2O_4\), the equilibrium constant K′ is given by the inverse expression:

    \[K'=\dfrac{[N_2O_4]}{[NO_2]^2} \label{Eq13}\]

    Consider another example, the formation of water: \(2H_{2(g)}+O_{2(g)} \rightleftharpoons 2H_2O_{(g)}\). Because \(H_2\) is a good reductant and \(O_2\) is a good oxidant, this reaction has a very large equilibrium constant (\(K = 2.4 \times 10^{47}\) at 500 K). Consequently, the equilibrium constant for the reverse reaction, the decomposition of water to form \(O_2\) and \(H_2\), is very small: \(K′ = 1/K = 1/(2.4 \times 10^{47}) = 4.2 \times 10^{−48}\). As suggested by the very small equilibrium constant, and fortunately for life as we know it, a substantial amount of energy is indeed needed to dissociate water into \(H_2\) and \(O_2\).

    The equilibrium constant for a reaction written in reverse is the inverse of the equilibrium constant for the reaction as written originally.

    Example \(\PageIndex{3}\): The Haber Process

    At 745 K, K is 0.118 for the following reaction:

    \[N_{2(g)}+3H_{2(g)} \rightleftharpoons 2NH_{3(g)}\]

    What is the equilibrium constant for \(2NH_{3(g)} \rightleftharpoons N2(g)+3H_{2(g)}\) at 745 K?

    Given: balanced equilibrium equation, K at a given temperature, and equations of related reactions

    Asked for: values of \(K\) for the reverse reaction

    Strategy:

    Write the equilibrium constant expression for the given reaction and for the reverse reaction. From these expressions, calculate \(K\) for each reaction.

    Solution:

    The equilibrium constant expression for the given reaction of \(N_{2(g)}\) with \(H_{2(g)}\) to produce \(NH_{3(g)}\) at 745 K is as follows:

    \[K=\dfrac{[NH_3]^2}{[N_2][H_2]^3}=0.118\]

    This reaction is the reverse of the one given, so its equilibrium constant expression is as follows:

    \[K'=\dfrac{1}{K}=\dfrac{[N_2][H_2]^3}{[NH_3]^2}=\dfrac{1}{0.118}=8.47\]

    Exercise \(\PageIndex{3}\)

    At 527°C, the equilibrium constant for the reaction

    \[2SO_{2(g)}+O_{2(g)} \rightleftharpoons 2SO_{3(g)} \nonumber\]

    is \(7.90 \times 10^4\). Calculate the equilibrium constant for the following reaction at the same temperature:

    \[2SO_{3(g)} \rightleftharpoons 2SO_{2(g)}+O_{2(g)} \nonumber\]
    Answer

    \(1.27 \times 10^{−5}\)

     

    Heterogeneous Equilibria

    When the products and reactants of an equilibrium reaction form a single phase, whether gas or liquid, the system is a homogeneous equilibrium. In such situations, the concentrations of the reactants and products can vary over a wide range. In contrast, a system whose reactants, products, or both are in more than one phase is a heterogeneous equilibrium, such as the reaction of a gas with a solid or liquid, or the reaction of a solute with the solvent to form a new, different solute. In these heterogeneous equilibria, the pure liquids and pure solids are assigned an activity of 1.

    This standard convention causes quite a bit of confusion because the treatment of the activity of a pure solid, pure liquid, or solvent differs from the treatment of the activity of a gas or a solute in a mixture. The true law of mass action is a ratio of activities of all the reactants and products. However, to simplify measurements and calculations, the activity of any gas or any solute can be approximated by its molarity. The activity of a pure solid or a pure liquid or a solvent is never approximated by its concentration. Instead, the activity of the pure solid, or pure liquid, or solvent is defined as having a value of 1.

    Consider the following reaction, which is used in the final firing of some types of pottery to produce brilliant metallic glazes:

    \[CO_{2(g)}+C_{(s)} \rightleftharpoons 2CO_{(g)}\]

    The glaze is created when metal oxides are reduced to metals by the product, carbon monoxide. The equilibrium constant expression for this reaction is as follows:

    \[K=\dfrac{a_{CO}^2}{a_{CO_2}a_{C}}=\dfrac{[CO]^2}{[CO_2][1]}=\dfrac{[CO]^2}{[CO_2]}\]

    Although the concentrations of pure liquids or solids are not written explicitly in the equilibrium constant expression, these substances must be present in the reaction mixture for chemical equilibrium to occur. Whatever the concentrations of \(CO\) and \(CO_2\), the system described above will reach chemical equilibrium only if excess solid carbon has been added so that some solid carbon is still present once the system has reached equilibrium. As shown in Figure 4, it does not matter whether 1 g or 100 g of solid carbon is present; in either case, the composition of the gaseous components of the system will be the same at equilibrium.

    imageedit_4_5409951422.jpg

    Figure 4: Effect of the Amount of Solid Present on Equilibrium in a Heterogeneous Solid–Gas System. In the system, the equilibrium composition of the gas phase at a given temperature, 1000 K in this case, is the same whether a small amount of solid carbon (left) or a large amount (right) is present.

    Example \(\PageIndex{4}\)

    Write each expression for K for the following equilibrium reactions.

    \[ PCl_{3(l)}+Cl_{2(g)} \rightleftharpoons PCl_{5(s)}\]

    \[ Fe_3O_{4(s)}+4H_{2(g)} \rightleftharpoons 3Fe_{(s)}+4H_2O_{(g)}\]

    Given: balanced equilibrium equations

    Asked for: expression for K

    Strategy:

    Find K by writing each equilibrium constant expression as the ratio of the activities of the products and reactants, each raised to its coefficient in the chemical equation. Then substitute the appropriate concentration or activity to arrive at the common form of the law of mass action

    Solution:

    The first reaction contains a pure solid \(PCl_5\) and a pure liquid \(PCl_3\). As pure substances, their activities are defined as "1", so they do not appear explicitly in the equilibrium constant expression. So

    \[ K=\dfrac{a_{PCl_5}}{a_{PCl_3}a_{Cl_2}} = \dfrac{1}{(1)[Cl_2]} =\dfrac{1}{[Cl_2]}\]

    The second reaction contains two pure solids \(Fe_3O_4\) and \(Fe\), which both have an activity defined as "1", and so do not appear explicitly in the equilibrium constant expressions. The concentrations of the two gases do, however, appear in the expressions:

    \[ K= \dfrac{a_{Fe}^3 a_{H_2O}^4}{a_{Fe_3O_4} a_{H_2}^4} = \dfrac{(1)^3[H_2O]^4}{(1)[H_2]^4}=\dfrac{[H_2O]^4}{[H_2]^4}\]

    Exercise \(\PageIndex{4}\)

    EXERCISE 7

    Write the expression for K for the following reactions.

    \[ CaCO_{3(s)}\rightleftharpoons CaO_{(s)}+CO_{2(g)}\]

    \[C_6H_{12}O_{6(s)}+6O_{2(g)}\rightleftharpoons 6CO_{2(g)}+6H_2O_{(g)}\]

    Answer

    \[ K= \dfrac{a_{CaO} a_{CO_2}}{a_{CaCO_3}} =\dfrac{(1)[CO_2]}{1} = [CO_2] \]

    \[ K= \dfrac{a_{CO_2}^6 a_{H_2O}^6}{a_{C_6H_{12}O_6} a_{O_2}^6} = \dfrac{[CO_2]^6[H_2O]^6}{(1)[O_2]^6}=\dfrac{[CO_2]^6[H_2O]^6}{[O_2]^6}\]

    For reactions carried out in solution, the solvent is assumed to be pure, and therefore is assigned an activity equal to 1 in the equilibrium constant expression. The activities of the solutes are approximated by their molarities. The result is that the equilibrium constant expressions appear to only depend upon the concentrations of the solutes.

    The activities of pure solids, pure liquids, and solvents are defined as having a value of '1'. Often, it is said that these activities are "left out" of equilibrium constant expressions. This is an unfortunate use of words. The activities are not "left out" of equilibrium constant expressions. Rather, because they have a value of '1', they do not change the value of the equilibrium constant when they are multiplied together with the other terms.

    Summary

    The ratio of the rate constants for the forward and reverse reactions at equilibrium is the equilibrium constant (\(K\)), a unitless quantity. The composition of the equilibrium mixture is therefore determined by the magnitudes of the forward and reverse rate constants at equilibrium. Under a given set of conditions, a reaction will always have the same \(K\). For a system at equilibrium, the law of mass action relates \(K\) to the ratio of the equilibrium concentrations of the products to the concentrations of the reactants raised to their respective powers to match the coefficients in the equilibrium equation. The ratio is called the equilibrium constant expression. When a reaction is written in the reverse direction, \(K\) and the equilibrium constant expression are inverted. An equilibrium system that contains products and reactants in a single phase is a homogeneous equilibrium; a system whose reactants, products, or both are in more than one phase is a heterogeneous equilibrium.

    • The law of mass action describes a system at equilibrium in terms of the concentrations of the products and the reactants.
    • Equilibrium constant expression (law of mass action): \[K=\dfrac{[C]^c[D]^d}{[A]^a[B]^b} \]

    Contributors

    Modified by Tom Neils (Grand Rapids Community College)