And if not, maybe you know ME well enough

This could be much shorter using algorithms, I'll look into it...