refactoring to lambda