Added the codes for exercise 6.4