Finished the problem not from the book.