Simplify the mDiff function

Added a minValue and addContext function literal inside mDiff to make reading/managing the code simpler.