fixed some array bugs