Solution to exercise 7