refactored range to implement Iterable directly