custom query fixes