added code for Problem 4.10 (same as code for Problem 4.7(ii))