Fix create new document logic