solved exercise 25 in chapter3