adding toArray method