First draft NS code