Customize the toArray method