Generate get_ns/1 function