Finished the problem, there was an issue with copying the arrays.