i am trying to override specific disposition cause coming from leg B and sending the modified cause to leg A

using,
https://freeswitch.org/confluence/display/FREESWITCH/Cause+Code+Substitution+Example

the lua file returns
sip_invite_failure_status variable as '-ERR No such channel!' and not the code 480
However, from sip trace i can see '480 temporary unavailable' from leg B and because of that my lua script which i am calling before bridge application is not able to override the cause from 480 to 503
What i am missing?