improve data to array conversion