added debug hooks to query