updated ch01 code