added BeforeInvoke and AfterInvoke methods