Converted the last function not using the book data structure.