adding problem 7, slow solution