Implemented problem 22