Fix bad query