fixing document creation bugs