Maybe the most disgusting thing I've ever had to code ever in my life