more query fixes