fix complex subselects