added a function to check and overwrite hashes if they differ