clean up the diffing code to be simpler logic