Solution to new exercise 4