added for loop for arrays of objects