some logic fixes in duplicate entry code