fix broken query statement