Added the codes for exercise 7.2