Merge changes from upstream

coverted for-loop to angular.forEach. Seems to help, but not conslusive