fixed double document creation bug