Fixed querying for ranges.