added option to keep the oldest duplicate (rather than the newest)