add code from ch1 to ch5
merge from initial commit