add before and after function