fixed issue with matching queries with indexes