some refactoring in updateDataForAllAgents