fixed null pointer exception on delete