improved query matching