add before and after dispatch hooks