I'm very ashamed of this, but its efficient enough for the time being...