Simplified code for exercise 3.59 part b)