Dug up this old code and streamlined it