cleaned up for loop for iterating over objects keys