extract document structure abstraction to own class