Attempt to optimize with subqueries