solved exercise 1 in chapter5