This is now the code by pandanomic. I am a disaster trying to merge stuff