HW 4 2) b) done although possibly inelegant solution - TBD: refine it?