bug fix on duplication of rows