fixing "exists" query.