To wrap ns_return first rename it to something else (rename ns_return _real_ns_return), then define your own proc that takes the same # of arguments as the original ns_return. Within that proc when you're ready to return data to the user, call the _real_ns_return.