partial solution for Chapter 4: