Fix bugs with array