finished code example in section 5, chapter7!