(forgive the spaghetti code -- I treated this more like a hackathon to get a proof of concept working)