Added named function expression to middleware