Function getQueries