Minor changes to the toArray() method