exercise 3.4
added explaining comments