Update to version of query with new logging