add anonymous function in each class