modified fine to take in Document object rather then plain text