use sub instead of slice