Refactor document to allow other input data structures