Bug fix for issue #89 - potential infinite loop when using multiple ranges