More or less functional, but waaaay to slow :( 
Making the commit, but looking for a different algorithm