completing the diff algo.