solved exercise 1 in chapter6