extracted Document.hs
refactoring