build query process