This a bit more complicated then necessary. Just move the updateAllAgents call into the !config.second branch and get rid of the updateAll variable.