some query fixes