added proper porting for ns

ported - has small error