add distinctBy method and implement distinct in terms of distinctBy