change array_splice to array_slice