Fix self destructive array problem