improved problem 7