Added debugging output for querying