Somewhat finished script. There are many limitations with the data structure