Implementing changes of Question 51 from textbook