Better way to slice array of unknown lenght