improving function ns definition