Starting the NMS work based on Hilton Bristow's code