Implemented problem 8.