detect beginning/ending of range