Fix toArray method