Fix pass by reference error with arrays