Array merging with wrong variable