refactor forEach