New version of this to use the oo stuff I've implented. Write out not working right as of now