make dedup slightly more generic