Adding solution to exercise 2.10