Finished the first part of problem 21