add protection and optim to delPath