improved delete script