Implement query dialog