improve inbound script robustness