implements diff and patch