Fixed an issue with the FixExceedingRanges function