Adding solution to exercise 7.