generate arrays correctly