Add code from chapter4