improved lookup pattern with generic relations, #457