fix functioning of the use of distinct and or_where to count results

fix functioning of the use of distinct and or_where to count results