query fixes