replaced prints with debug logging calls and added info logging calls
clarified code in the query method