fixed query problems