fix method of looping through object keys