adding ch5 examples and bug fixing