fixed slicing when ending is at boundary