Fixed a bug when counting the changes.