Query count fix