This is some code that was given to me by FuzzySpoon