refactoring: convert anonymous function to named function.