fixing distinct calls to support where clauses