Refactor forEach loops to lambdas