fix bad query