fixed slicing in rest function