Refactored query handling to support multiple fields / more operations