ch6: refactored code sample, addressed reviewers issues