modified after looking at Bill the Lizard's answer
exercise 2.29 up through section c done
exer 2.29 completed