remove unneeded code and use a for...of for the defeatcondition (and don't worry about caching)