added code for slice