Changed the code to fix the problem of equal arrays