solved exercise 3 from sw8