only saving and creating history if document has changed