updating ch5 code