Implement basic query handler