Updated diff algorithm for first iteration.