expanding interval refactored