fix memory leak when adding new array