fixing a bug where editting a text document 3 times throws an error. Oops.