MJG code exercise (revised) - 8/9/2013