Then I still do not understand properly after your last comment.
Note that $rc can be updated by any kamailio action, so you should save its value in a $var(...) if you want to use it later. If you do an xlog(), after it the $rc is updated to the return of xlog().