restructure matrix loading return arguments