Implemented problem 6 in JfC