added all code for this chapter