code for exercise 1