Add codes for exercise 2.1