fixed broken query