added code snippet of chap6