fixed bad queries conditions