I do think that I have come uo with an really bad algorithm