Refactoring: Lambdas instead of for-loops