add after() and before() function to the BaseController class