solved ex2 from sw2