Added the solution to exercise 3.6