solved exercise 13 in chapter5