A solution for exercise 16.15