corrected duplicated_rows function