Fixed a bug with duplicate rows