refactor remove_deplicates method