added check for setting the slice