It is impossible, as I said the script cannot delete units it can only spawn new ones. If you tried to do it your cavalry would still be there but now with newly spawned infantry replacements as well. The basic mechanics of the idea are not possible let alone problems introduced by having such a potentially large scirpt.