refactor diff and outerJoin