fix a bug produced by not setting deleted var to NULL