move toDelete above assert