fix bug with dynamic arrays