added further method for writeDocument