handle before/after callbacks