change for loop to use lodash's for each