consolidate diffing logic