add code examples for ch5 and ch6