fixed the bug in when start and end are equal (range(1,1) -> [1])