code for ex8
ex8 finished
only ex6 missing