fix runtime error caused by wrong position of arrays