rewrite consing nested relation