Add visitors query and refactor query.js