fixed bug in array write