Added the codes for exercise 6.5