finished adding appendix D, full code from book