fixed weird arraylist bug by reinitializing xi in the loop