Implemented toArray() method