refine document alignment