A double array + loop would have been more elegant, but this is OK too.