generalized a decorator and callback