Added second part of the code

Added the second part for the third chapter