using distinct instead of group