shitty code, but it works