re-implement problem 7