bug fix: verify NULL before delete