fix attribute count query