For this
if ($did == 28) { did -r $dname 1 $remove($did(1),$right($did(1),1)) }
Try the below
if ($did == 28) { did -a $dname 1 $remove($did(1),$right($did(1),1)) }