you can probably use $request which is initialized at the beginning of this function