added range check in generateRangePosition()