Adaptation of Chapter 4 example.