Roughly working, albeit with shitty code