Wait why should the length of both datasets be the same? Actually, I hope you don’t mind, it’s very hard to understand this code. Can you maybe make it a bit more formal so I can get a good idea of what you are trying to do?