adding chapter2 code