added debug log to check queries