move up lambdas to ordinary functions for better performance