first pass of document