included edits from Code Review to use iterate, however still needs to be examined to compile.