fixed query handling