problem 6
better p6