add codes in chapter7