optimizing array conversion