nested query improved; still missing CTE