solve problem 6
solve problem 7
solve problem 8