Completed Problem 17, but it's kind of sloppy