improved solution 7. Started problem 8
solved problem 9