add local query logger
more refactoring