bug on document

-document created new state everytime it was saved isntead of when being
updated.