Optimize query selector