updated for range queries