refactored. consolidated both dedupe and compare functions in one class