Updated NMS Code