code for chap 4