fixed create_document so it returns a Document instance