correcting diff algo
more simplified form of diff algo.