some refactoring to boost::irange