solved problem 3 though not very nicely