fix bug in flex array