rewrote diff check code