query selection fix