restore toArray() method