solved exercise 14 in chapter5