Working version based upon the example in the assignment