adding separate function for creating queries