Implemented listing 1, chapter 8.
implemented listing 2, Chapter 7