move 'distinct' to core code.