solved exercise14 in chapter3