Refactored kernel functions to use lambdas directly