improve indexing by ranges, ref #287