added query debugging