subquery bug