Add codes for exercise 2.6