Problem 1 implemented, untested.