Spaghetti code monster done. I'm gonna refactor this mess asap