rough prototype for filtering on relations